<template>
  <div class="section user-section">
    <div class="head">
      <van-nav-bar class="nav-bar">
        <template #title>
          <div class="title">学院动态</div>
        </template>
      </van-nav-bar>
    </div>
    <van-swipe :autoplay="3000" lazy-render>
      <van-swipe-item v-for="image in swiperList" :key="image.id">
        <img :src="image.url" class="swipeImg" />
      </van-swipe-item>
    </van-swipe>
    <div style="margin-bottom: 1.8rem">
      <div
        class="reportCard"
        v-for="article in formState.articleList"
        :key="article.id"
        @click="seeArticle(article.txtsrc)"
      >
        <van-card :thumb="article.imgsrc">
          <template #title>
            <div class="title">
              {{ article.title }}
            </div>
          </template>
          <template #desc>
            <div class="desc">{{ article.preview }}</div>
          </template>
        </van-card>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { Dialog, Toast } from "vant";
import { useStore } from "vuex";
import { getArticle } from "/@/api/branch";
const router = useRouter();
const formState = reactive({
  articleList: [],
});

onMounted(() => {
  getArticle(
    {
      articleType: "党日活动",
    },
    (res) => {
      if (res.code === 0) {
        formState.articleList = res.articleList;
      }
    }
  );
});

const seeArticle = (src) => {
  window.location.href = src;
  window.open();
};

const swiperList = [
  {
    id: 0,
    type: "image",
    url: "https://p5.itc.cn/q_70/images03/20210316/b3466c79e595436c9cdc29339df2fcfa.png",
  },
  {
    id: 1,
    type: "image",
    url: "https://p7.itc.cn/q_70/images03/20210316/77ffbe054056472c97d8d610ded9b881.png",
  },
  {
    id: 2,
    type: "image",
    url: "https://p2.itc.cn/q_70/images03/20210316/bbc0cb57100644cf9866a68939036cbe.png",
  },
  {
    id: 3,
    type: "image",
    url: "https://p2.itc.cn/q_70/images03/20210316/447b151cc082403cb2ccd6ca94c20ffd.png",
  },
  {
    id: 4,
    type: "image",
    url: "https://p5.itc.cn/q_70/images03/20210316/ef988ea8d9f1467390b9e1fe5e655e10.png",
  },
  {
    id: 5,
    type: "image",
    url: "https://p8.itc.cn/q_70/images03/20210316/c6096c5a543640e1ab664a148f8ee9b3.png",
  },
  {
    id: 6,
    type: "image",
    url: "https://p0.itc.cn/q_70/images03/20210316/ed604b89d0c0482aa0c32d05370e69a3.png",
  },
  {
    id: 7,
    type: "image",
    url: "https://p7.itc.cn/q_70/images03/20210316/dbd5ad050f71486785a729e6c6e5f528.png",
  },
  {
    id: 8,
    type: "image",
    url: "https://p3.itc.cn/q_70/images03/20210316/53787a57b5544892b57a3c671764a0ad.png",
  },
  {
    id: 9,
    type: "image",
    url: "https://p8.itc.cn/q_70/images03/20210316/fc4c0924ea99452eade521dae6513492.png",
  },
  {
    id: 10,
    type: "image",
    url: "https://p2.itc.cn/q_70/images03/20210316/9af05716acfd4a1bb6f5fec5ead71983.png",
  },
  {
    id: 11,
    type: "image",
    url: "https://p0.itc.cn/q_70/images03/20210316/bd33811fe436483d9b56db12804714c2.png",
  },
  {
    id: 12,
    type: "image",
    url: "https://p4.itc.cn/q_70/images03/20210316/866a64f6bf504ff1b3dc60e0d0950dee.png",
  },
  {
    id: 13,
    type: "image",
    url: "https://p9.itc.cn/q_70/images03/20210316/e6d339628a604a93aa08cd0711e9b644.png",
  },
  {
    id: 14,
    type: "image",
    url: "https://p6.itc.cn/q_70/images03/20210316/bf58a7682d574438bbef69bdbd540e2e.png",
  },
  {
    id: 15,
    type: "image",
    url: "https://p7.itc.cn/q_70/images03/20210316/5c1ed866690549cb8ccb34d54a106c07.png",
  },
  {
    id: 16,
    type: "image",
    url: "https://p7.itc.cn/q_70/images03/20210316/8120af1a9a344c5e91ff318caeb76e9a.png",
  },
  {
    id: 17,
    type: "image",
    url: "https://p8.itc.cn/q_70/images03/20210316/d9b58ec2fe9f484f80f37b8668479bab.png",
  },
  {
    id: 18,
    type: "image",
    url: "https://p1.itc.cn/q_70/images03/20210316/65bf83524d3b4f389383ca7fc38c451e.png",
  },
  {
    id: 19,
    type: "image",
    url: "https://p4.itc.cn/q_70/images03/20210316/f2d01f6f98294495a7b702d27c3c79d2.png",
  },
  {
    id: 20,
    type: "image",
    url: "https://p6.itc.cn/q_70/images03/20210316/49331c1046b64d698020fd7fd7aa8802.png",
  },
  {
    id: 21,
    type: "image",
    url: "https://p5.itc.cn/q_70/images03/20210316/db4689e7422b4c1789324ea94a7e8054.png",
  },
  {
    id: 22,
    type: "image",
    url: "https://p5.itc.cn/q_70/images03/20210316/75d7cdecb5a24f0d8599352ccaf74ba6.png",
  },
  {
    id: 23,
    type: "image",
    url: "https://p3.itc.cn/q_70/images03/20210316/9664f4d06f55434eaba06cf12e97122c.png",
  },
  {
    id: 24,
    type: "image",
    url: "https://p0.itc.cn/q_70/images03/20210316/b4ab98b20e684c7e8dd21be6222d4073.png",
  },
  {
    id: 25,
    type: "image",
    url: "https://p5.itc.cn/q_70/images03/20210316/ec9d57702cd640a39ec5cd7a30994af8.png",
  },
  {
    id: 26,
    type: "image",
    url: "https://p7.itc.cn/q_70/images03/20210316/c5c26009f88148b1837d97d9e30b10cb.png",
  },
  {
    id: 27,
    type: "image",
    url: "https://p9.itc.cn/q_70/images03/20210316/16f3ea6e601a49868a2cf3c25d117b5a.png",
  },
  {
    id: 28,
    type: "image",
    url: "https://p1.itc.cn/q_70/images03/20210316/1a5ec2dce13f470f8af1acd6ceccb980.png",
  },
  {
    id: 29,
    type: "image",
    url: "https://p5.itc.cn/q_70/images03/20210316/1ae0d8306be64a7ebfeda6496c0f08ad.png",
  },
  {
    id: 30,
    type: "image",
    url: "https://p6.itc.cn/q_70/images03/20210316/827949d2e71f4118bcda8f057ddb318c.png",
  },
];
</script>

<style lang="scss" scoped>
.user-section {
  background: var(--yu-gray-color--light);
  min-height: 100vh;
  .reportCard {
    margin: 3px;
    border-radius: 3px;
    padding: 5px;
    .title {
      display: flex;
      align-items: center;
      justify-content: left;
      margin: 7px;
      font-size: large;
      font-weight: bold;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      width: 5.5rem;
    }
    .desc {
      display: flex;
      align-items: center;
      margin: 7px;
      justify-content: center;
      font-size: small;
      color: var(--yu-color-disabled);
    }
  }

  .swipeImg {
    width: 100%;
    height: 100%;
    background-size: 100% auto;
  }
  .head {
    height: 1.2rem;
    position: relative;
    .nav-bar {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      background: var(--yu-linear-bg-color);
      border: none;
      .van-icon {
        color: var(--yu-white-color);
      }
      .title {
        color: var(--yu-white-color);
      }
      &:after {
        border: none;
      }
    }
    .head-bg {
      height: 150px;
      background: var(--yu-linear-bg-color);
      position: relative;
      overflow: hidden;
      width: 100%;
      img {
        display: inline-block;
        position: absolute;
        width: 80px;
        height: auto;
        opacity: 0.2;
        &.img1 {
          top: 0;
          right: 0;
        }
        &.img2 {
          bottom: 0;
          left: 0;
        }
      }
    }
  }

  .user-info {
    position: absolute;
    top: 66px;
    left: 13px;
    width: calc(100% - 26px);
    z-index: 9;

    .card-body-wrapper {
      .avatar {
        width: 60px;
        height: 60px;
        overflow: hidden;
        border-radius: 50%;
        margin-right: 16px;
        box-shadow: var(--yu-border-shadow--light);
        img {
          width: 100%;
          height: 100%;
        }
      }
      .info {
        color: rgba(36, 45, 61, 1);
        font-size: 12px;
        line-height: 18px;
        padding-top: 10px;
        text-align: left;
        width: calc(100% - 60px - 16px);
        .user-name {
          margin-bottom: 4px;
          font-weight: 600;
        }
      }
    }
  }

  .body {
    padding: 0 13px;
    margin-top: 10px;
  }
  .user-info-card {
    display: block;
    width: 100%;
    padding: 0;
    margin-bottom: 8px;
  }
  .user-info-list {
    font-size: 15px;
  }
}
</style>
